package com.miaosha.ms_02.controller;

import com.miaosha.ms_02.prefix.UserKey;
import com.miaosha.ms_02.redis.JedisService;
import com.miaosha.ms_02.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description //TODO
 * @Author Administrator
 * @DATE 2020/9/13 21:00
 **/
@RestController
@RequestMapping("/redis")
public class RedisController {

    @Autowired
    private JedisService jedisService;

    @RequestMapping("/getByKey/{key}")
    public Result<String> getByKey(@PathVariable String key) {
        String value = jedisService.get(UserKey.USERKEY_BY_ID,key, String.class);
        return Result.success(value);
    }

    @RequestMapping("/setValue/{key}/{value}")
    public Result<String> getByKey(@PathVariable String key, @PathVariable String value) {
        jedisService.set(UserKey.USERKEY_BY_ID,key, value, String.class);
        return Result.success(value);
    }
}
